# coding=utf-8
from django.db import models
import datetime

class ResearchGroup(models.Model):
    group_name_en = models.CharField(verbose_name='Group Name', max_length=63)
    group_name_zh = models.CharField(verbose_name='小组名称', max_length=31)
    group_home_en = models.TextField(verbose_name='Home page', blank=True)
    group_home_zh = models.TextField(verbose_name='小组首页', blank=True)
    group_rank = models.IntegerField(verbose_name='Rank', default=0)
    group_tag = models.CharField(verbose_name='Abbreviation', unique=True, help_text='Enter an English short name of the group without space in lower case', max_length=63)

    def __unicode__(self):
        return self.group_name_zh

    class Meta:
        ordering = ['-group_rank']
        verbose_name = 'Research Group'

class ResearchArticle(models.Model):
    article_title_en = models.CharField(verbose_name='Titile', max_length=127)
    article_title_zh = models.CharField(verbose_name='标题', max_length=31)
    article_content_en = models.TextField(verbose_name='Content', blank=True)
    article_content_zh = models.TextField(verbose_name='内容', blank=True)
    article_datetime = models.DateTimeField(verbose_name='Publish Date', default=datetime.datetime.now())
    article_status = models.BooleanField(verbose_name='Draft', default=False)
    article_group = models.ForeignKey(ResearchGroup)

    def __unicode__(self):
        return self.article_title_zh

    class Meta:
        ordering = ['-article_datetime']
        verbose_name = 'Research Article'

class ResearchPublication(models.Model):
    publication_name_en = models.CharField(verbose_name='Press Name', max_length=127)
    publication_name_zh = models.CharField(verbose_name='出版物类别', max_length=31)
    publication_content_en = models.TextField(verbose_name='Content', blank=True)
    publication_content_zh = models.TextField(verbose_name='内容', blank=True)
    publication_rank = models.IntegerField(verbose_name='Rank', default=0, help_text='High value means displaying former')

    def __unicode__(self):
        return '%s %s' % (self.publication_name_en, self.publication_content_zh)

    class Meta:
        ordering = ['-publication_rank']
        verbose_name = 'Research Publication'
